package com.zhxh.nzpos.goods;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.zhxh.nzpos.BaseActivity;
import com.zhxh.nzpos.R;
import com.zhxh.nzpos.login.ImageAdapter;
import com.zhxh.nzpos.setting.PriceSettingActivity;

/**
 * 系统主界面
 * 
 * @author wangzt
 *
 */
public class GoodsMainActivity extends BaseActivity {

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods_main);
        initViews();
    }
	
	private void initViews() {
		GridView gridView = (GridView) findViewById(R.id.grid_main);

		ArrayList<HashMap<String, Object>> imagelist = new ArrayList<HashMap<String, Object>>();
		HashMap<String, Object> map1 = new HashMap<String, Object>();
		map1.put("image", R.drawable.goods_category);
	//	map1.put("text", getString(R.string.goods_category) );
		
		imagelist.add(map1);
		HashMap<String, Object> map2 = new HashMap<String, Object>();
		map2.put("image", R.drawable.goods_info);
		//map2.put("text",getString(R.string.goods_information)  );
		imagelist.add(map2);
/*		HashMap<String, Object> map3 = new HashMap<String, Object>();
		map3.put("image", R.drawable.goods_return);
		//map3.put("text",getString( R.string.goods_back) );
		imagelist.add(map3);
		HashMap<String, Object> map4 = new HashMap<String, Object>();
		map4.put("image", R.drawable.goods_supplier);
	//	map4.put("text",getString( R.string.goods_supply) );
		imagelist.add(map4);*/

		HashMap<String, Object> map5 = new HashMap<String, Object>();
		map5.put("image", R.drawable.setting_price);
		//map1.put("text", getResources().getString(R.string.price_setting));
		imagelist.add(map5);
		
		
		ImageAdapter simpleAdapter = new ImageAdapter(this, imagelist,
				R.layout.goods_grid_item, new String[] { "image"},
				new int[] { R.id.grid_image });
		gridView.setAdapter(simpleAdapter);
		
		gridView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
					long arg3) {
				Intent intent = new Intent();
				switch (pos) {
				case 0:
					intent.setClass(getApplicationContext(), GoodsCategoryActivity.class);
					startActivity(intent);
					break;
				case 1:
					intent.setClass(getApplicationContext(), GoodsManageActivity.class);
					startActivity(intent);
					break;
/*				case 2:
					intent.setClass(getApplicationContext(), GoodsReturnActivity.class);
					startActivity(intent);
					break;
				case 3:
					intent.setClass(getApplicationContext(), GoodsSuppliersActivity.class);
					startActivity(intent);
					break;*/
				case 2:
					intent.setClass(getApplicationContext(), PriceSettingActivity.class);
					startActivity(intent);
					break;
				}
				
				
			}
		});
	}
	
}
